/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.AirconditionBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class AirconditionDAO
/*     */ {
/*  22 */   private static final Log log = LogFactory.getLog(AirconditionDAO.class);
/*     */ 
/*  24 */   private dbConnector dbcon = null;
/*  25 */   private SimpleDateFormat open = new SimpleDateFormat("yyyy-MM-dd");
/*  26 */   private SimpleDateFormat fresh = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*     */ 
/*     */   private void dbConInit() {
/*  29 */     if (this.dbcon == null)
/*  30 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  34 */     if (this.dbcon != null)
/*  35 */       this.dbcon.closeAll();
/*  36 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getAirconditionList(Map condition)
/*     */   {
/*  41 */     ListContentsBFO bfo = new ListContentsBFO();
/*  42 */     int start = Integer.parseInt(condition.get("start").toString());
/*  43 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  44 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  45 */     ResultSet rs = null;
/*  46 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  49 */       dbConInit();
/*  50 */       String strSQL = " select count(id) from aircondition where btscode = '" + strBtscode + "' ";
/*  51 */       log.info(strSQL);
/*  52 */       rs = this.dbcon.execQuery(strSQL);
/*  53 */       if (rs.next()) {
/*  54 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  56 */       strSQL = " select * from aircondition where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  57 */       log.info(strSQL);
/*  58 */       rs = this.dbcon.execQuery(strSQL);
/*  59 */       while (rs.next()) {
/*  60 */         AirconditionBO bo = new AirconditionBO();
/*  61 */         bo.setId(rs.getString("id"));
/*  62 */         bo.setBtscode(rs.getString("btscode"));
/*  63 */         bo.setBtsname(rs.getString("btsname"));
/*  64 */         bo.setType(rs.getString("type"));
/*  65 */         bo.setManufacturer(rs.getString("manufacturer"));
/*  66 */         bo.setCapacity(rs.getString("capacity"));
/*  67 */         bo.setNum(rs.getString("num"));
/*  68 */         bo.setOpentime(rs.getDate("registtime"));
/*  69 */         bo.setFence(rs.getString("fence"));
/*  70 */         bo.setMaintenance(rs.getString("maintenance"));
/*  71 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  72 */         bo.setMemo(rs.getString("memo"));
/*  73 */         bo.setAircPowerType(rs.getString("aircPowerType"));
/*  74 */         bo.setAircType(rs.getString("aircType"));
/*  75 */         bo.setAircInSideSize(rs.getString("aircInSideSize"));
/*  76 */         bo.setAircOutSideSize(rs.getString("aircOutSideSize"));
/*     */ 
/*  78 */         list.add(bo);
/*     */       }
/*  80 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  83 */       e.printStackTrace();
/*  84 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  87 */       dbConClose();
/*     */     }
/*  89 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean saveAircondition(AirconditionBO bo)
/*     */   {
/*  95 */     log.info("添加--空调---开始");
/*  96 */     boolean flag = true;
/*     */     try
/*     */     {
/*  99 */       dbConInit();
/* 100 */       StringBuffer sqlBuf = new StringBuffer();
/* 101 */       sqlBuf.append(" insert into aircondition ( btscode, btsname, type, manufacturer, capacity,");
/* 102 */       sqlBuf.append(" num, registtime, fence, maintenance, refreshtime, memo, aircPowerType,");
/* 103 */       sqlBuf.append(" aircType, aircInSideSize, aircOutSideSize ) values ( ");
/* 104 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 105 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 106 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 107 */       sqlBuf.append(" '" + bo.getManufacturer() + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getCapacity() + "' ,");
/* 109 */       sqlBuf.append(" '" + bo.getNum() + "' ,");
/* 110 */       sqlBuf.append(" '" + this.open.format(bo.getOpentime()) + "' ,");
/* 111 */       sqlBuf.append(" '" + bo.getFence() + "' ,");
/* 112 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 113 */       sqlBuf.append(" '" + this.fresh.format(new Date()) + "' ,");
/* 114 */       sqlBuf.append(" '" + bo.getMemo() + "' ,");
/* 115 */       sqlBuf.append(" '" + bo.getAircPowerType() + "' ,");
/* 116 */       sqlBuf.append(" '" + bo.getAircType() + "' ,");
/* 117 */       sqlBuf.append(" '" + bo.getAircInSideSize() + "' ,");
/* 118 */       sqlBuf.append(" '" + bo.getAircOutSideSize() + "' )");
/*     */ 
/* 120 */       log.info(sqlBuf.toString());
/* 121 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 125 */       flag = false;
/* 126 */       e.printStackTrace();
/* 127 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 130 */       dbConClose();
/*     */     }
/* 132 */     log.info("添加--空调---结束");
/* 133 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updateAircondition(AirconditionBO bo)
/*     */   {
/* 138 */     log.info("修改--空调---开始");
/* 139 */     boolean flag = true;
/*     */     try
/*     */     {
/* 142 */       dbConInit();
/* 143 */       StringBuffer sqlBuf = new StringBuffer();
/* 144 */       sqlBuf.append(" update  aircondition  set ");
/* 145 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 146 */       sqlBuf.append(" manufacturer = '" + bo.getManufacturer() + "' ,");
/* 147 */       sqlBuf.append(" capacity = '" + bo.getCapacity() + "' ,");
/* 148 */       sqlBuf.append(" num = '" + bo.getNum() + "' ,");
/* 149 */       sqlBuf.append(" registtime = '" + this.open.format(bo.getOpentime()) + "' ,");
/* 150 */       sqlBuf.append(" fence = '" + bo.getFence() + "' ,");
/* 151 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 152 */       sqlBuf.append(" refreshtime = '" + this.fresh.format(new Date()) + "' ,");
/* 153 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ,");
/* 154 */       sqlBuf.append(" aircPowerType = '" + bo.getAircPowerType() + "' ,");
/* 155 */       sqlBuf.append(" aircType = '" + bo.getAircType() + "' ,");
/* 156 */       sqlBuf.append(" aircInSideSize = '" + bo.getAircInSideSize() + "' ,");
/* 157 */       sqlBuf.append(" aircOutSideSize = '" + bo.getAircOutSideSize() + "' ");
/* 158 */       sqlBuf.append(" where id = '" + bo.getId() + "'");
/*     */ 
/* 160 */       log.info(sqlBuf.toString());
/* 161 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 165 */       flag = false;
/* 166 */       e.printStackTrace();
/* 167 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 170 */       dbConClose();
/*     */     }
/* 172 */     log.info("修改--空调---结束");
/* 173 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deleteAircondition(String strID)
/*     */   {
/* 178 */     log.info("删除--空调[" + strID + "]---开始");
/* 179 */     boolean flag = true;
/*     */     try
/*     */     {
/* 182 */       dbConInit();
/* 183 */       StringBuffer sqlBuf = new StringBuffer();
/* 184 */       sqlBuf.append(" delete from   aircondition where  id = '" + strID + "' ");
/* 185 */       log.info(sqlBuf.toString());
/* 186 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 190 */       flag = false;
/* 191 */       e.printStackTrace();
/* 192 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 195 */       dbConClose();
/*     */     }
/* 197 */     log.info("删除--空调---结束");
/* 198 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getAirconditionByBtsName(Map condition)
/*     */   {
/* 203 */     ListContentsBFO bfo = new ListContentsBFO();
/* 204 */     int start = Integer.parseInt(condition.get("start").toString());
/* 205 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 206 */     String strBtsName = condition.get("btsName").toString();
/* 207 */     ResultSet rs = null;
/* 208 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 211 */       dbConInit();
/* 212 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 213 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 215 */       String strSQL = " select count(id) from aircondition where  ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 216 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 217 */       log.info(strSQL);
/* 218 */       rs = this.dbcon.execQuery(strSQL);
/* 219 */       if (rs.next()) {
/* 220 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 222 */       strSQL = " select * from aircondition where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' )";
/* 223 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 224 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 225 */       log.info(strSQL);
/* 226 */       rs = this.dbcon.execQuery(strSQL);
/* 227 */       while (rs.next()) {
/* 228 */         AirconditionBO bo = new AirconditionBO();
/* 229 */         bo.setId(rs.getString("id"));
/* 230 */         bo.setBtscode(rs.getString("btscode"));
/* 231 */         bo.setBtsname(rs.getString("btsname"));
/* 232 */         bo.setType(rs.getString("type"));
/* 233 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 234 */         bo.setCapacity(rs.getString("capacity"));
/* 235 */         bo.setNum(rs.getString("num"));
/* 236 */         bo.setOpentime(rs.getDate("registtime"));
/* 237 */         bo.setFence(rs.getString("fence"));
/* 238 */         bo.setMaintenance(rs.getString("maintenance"));
/* 239 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 240 */         bo.setMemo(rs.getString("memo"));
/* 241 */         bo.setAircPowerType(rs.getString("aircPowerType"));
/* 242 */         bo.setAircType(rs.getString("aircType"));
/* 243 */         bo.setAircInSideSize(rs.getString("aircInSideSize"));
/* 244 */         bo.setAircOutSideSize(rs.getString("aircOutSideSize"));
/*     */ 
/* 246 */         list.add(bo);
/*     */       }
/* 248 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 251 */       e.printStackTrace();
/* 252 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 255 */       dbConClose();
/*     */     }
/* 257 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 262 */     ResultSet rs = null;
/* 263 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 266 */       dbConInit();
/* 267 */       String strSQL = " select * from aircondition where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' )";
/* 268 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 269 */       log.info(strSQL);
/* 270 */       rs = this.dbcon.execQuery(strSQL);
/* 271 */       while (rs.next()) {
/* 272 */         AirconditionBO bo = new AirconditionBO();
/* 273 */         bo.setId(rs.getString("id"));
/* 274 */         bo.setBtscode(rs.getString("btscode"));
/* 275 */         bo.setBtsname(rs.getString("btsname"));
/* 276 */         bo.setType(rs.getString("type"));
/* 277 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 278 */         bo.setCapacity(rs.getString("capacity"));
/* 279 */         bo.setNum(rs.getString("num"));
/* 280 */         bo.setOpentime(rs.getDate("registtime"));
/* 281 */         bo.setFence(rs.getString("fence"));
/* 282 */         bo.setMaintenance(rs.getString("maintenance"));
/* 283 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 284 */         bo.setMemo(rs.getString("memo"));
/* 285 */         bo.setAircPowerType(rs.getString("aircPowerType"));
/* 286 */         bo.setAircType(rs.getString("aircType"));
/* 287 */         bo.setAircInSideSize(rs.getString("aircInSideSize"));
/* 288 */         bo.setAircOutSideSize(rs.getString("aircOutSideSize"));
/*     */ 
/* 290 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 294 */       e.printStackTrace();
/* 295 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 298 */       dbConClose();
/*     */     }
/* 300 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.AirconditionDAO
 * JD-Core Version:    0.6.2
 */